package com.xxl.bean;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component("optLogger")
@Aspect
public class OptLogger {

    @Pointcut("within(com.xxl.service.impl..*)")
    public void servicePointCut(){}

    @Around("servicePointCut()")
    public Object logger(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("记录操作日志了...");
        Object obj = pjp.proceed();
        String method = pjp.getSignature().getName();
        String clazzName = pjp.getTarget().getClass().getName();
        System.out.println("执行了" + clazzName + "的" + method);
        return obj;
    }
}
